package com.atguigu.gmall.realtime.join;

import com.atguigu.gmall.realtime.app.BaseSQLApp;
import com.atguigu.gmall.realtime.util.SQLUtil;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @Author lzc
 * @Date 2023/4/23 14:23
 */
public class ConsumeLeftJoinWithSQLUpsertKafka extends BaseSQLApp {
    public static void main(String[] args) {
        new ConsumeLeftJoinWithSQLUpsertKafka().init(
            50004,
            2,
            "ConsumeLeftJoinWithSQLUpsertKafka"
        );
        
    }
    
    @Override
    protected void handle(StreamExecutionEnvironment env, StreamTableEnvironment tEnv) {
        tEnv.executeSql("create table ab(" +
                            "  id string, " +
                            "  name string, " +
                            "  c int, " +
                            "  age int," +
                            "  primary key(id) not enforced " +
                            ")" + SQLUtil.getUpsertKafkaDDL("ab_left_1", "json"));
    
        tEnv.sqlQuery("select sum(c) sum_id from ab group by id").execute().print();
    
    }
}
